<%--
  Created by IntelliJ IDEA.
  User: 吕天
  Date: 2022/12/29
  Time: 14:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/js/jquery-3.3.1.min.js"></script>
    <script>
        $(function(){
            $(":button").click(function(){
                let student = {
                    "id":$("[name=id]:text").val(),
                    "name":$("[name=name]:text").val(),
                    "age":$("[name=age]:text").val(),
                    "subject":$("[name=subject]:text").val(),
                    "address":$("[name=address]:text").val()};

                $.ajax({
                    "url":"http://localhost:8080/testAjax",
                    "type":"POST",
                    "dataType":"json",
                    "contentType":"application/json",
                    "data":JSON.stringify(student),
                    "success":function (data) {
                        console.log(data);
                    }
                });
            });
        });

    </script>
</head>
<body>
<div>
    <input type="text" name="id" placeholder="Id"><br>
    <input type="text" name="name" placeholder="Name"><br>
    <input type="text" name="age" placeholder="Age"><br>
    <input type="text" name="subject" placeholder="Subject"><br>
    <input type="text" name="address" placeholder="Address"><br>
    <input type="text" name="studyDate" placeholder="studyDate"><br>
    <input type="button" value="添加">
</div>
</body>
</html>